﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Practices.CompositeUI.UIElements;
using Kent.Boogaart.HelperTrinity;
using WPF = System.Windows.Controls;

namespace WPFCABShell.$safeprojectname$.ToolBar
{
	/// <summary>
	/// An implementation of <see cref="IUIElementAdapter"/> that adapts a <see cref="ToolBarTray"/> to allow
	/// <see cref="WPF.ToolBar"/>s to be added and removed from it.
	/// </summary>
	/// <remarks>
	/// <para>
	/// This class extends <see cref="GroupingUIAdapter{WPF.ToolBar}"/> and thus supports grouping and
	/// sorting of items within the <see cref="ToolBar"/>s added to the underlying <see cref="ToolBarTray"/>.
	/// </para>
	/// </remarks>
	public sealed class ToolBarTrayUIAdapter : UIElementAdapter<WPF.ToolBar>
	{
		private readonly ToolBarTray _toolBarTray;

		public ToolBarTrayUIAdapter(ToolBarTray toolBarTray)
		{
			ArgumentHelper.AssertNotNull(toolBarTray, "toolBarTray");
			_toolBarTray = toolBarTray;
		}

		protected override WPF.ToolBar Add(WPF.ToolBar item)
		{
			ArgumentHelper.AssertNotNull(item, "item");
			_toolBarTray.ToolBars.Add(item);
			return item;
		}

		protected override void Remove(WPF.ToolBar item)
		{
			ArgumentHelper.AssertNotNull(item, "item");
			_toolBarTray.ToolBars.Remove(item);
		}
	}
}
